﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using IdentityServer4.Models;
using IdentityServer4.Test;
namespace IdentityService
{
    public class Config
    {
        public static List<TestUser> GetUsers()
        {
            return new List<TestUser>
            {
                new TestUser
                {
                    SubjectId = "1",
                    Username = "li",
                    Password = "123456",
                    Claims=new List<Claim>(){ new Claim(ClaimTypes.Role,"Admin") }
                },
                new TestUser
                {
                    SubjectId = "2",
                    Username = "wang",
                    Password = "w12345"
                }
            };
        }
        public static List<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = "li.client",
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                    ClientSecrets =
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes = { "api1","api2" }
                }
            };
        }
        public static IEnumerable<ApiResource> GetApis()
        {
            return new List<ApiResource>
            {
                new ApiResource("api1", "My API"),
                new ApiResource("api2","My API2",new List<string>(){ClaimTypes.Role })
            };
        }
    }
}
